﻿#ifndef SERVER_H
#define SERVER_H

#include <QHttpServer>
#include <QFile>
#include <QFileInfo>
#include <QDir>
#include <optional>
#include <QWidget>


#include "ResultCode.h"
#include "HttpPartParse.h"
#include "SSqlconnectionPool.h"
#include "SJwt.h"
#include "QsLog.h"

#include <QBoxLayout>
#include <QLabel>
#include <QListView>
#include <QStandardItemModel>



class Server:public QWidget
{
	Q_OBJECT
private:
	QHttpServer m_server;

public:
	QHBoxLayout* m_total_layout{};

	//状态栏:
	QVBoxLayout* m_navigation_layout{};
	QLabel* m_titleLab{};
	QListView* m_navigation_view{};
	QStandardItemModel* m_navigation_model{};
	int m_total_interview_count = 0;

	//数据显示：
	QListView* m_data_view{};
	QStandardItemModel* m_data_model{};

signals:
	void ApiData(QString);

private:
	//检查token语句:
	std::optional<QByteArray> CheckToken(const QHttpServerRequest& request);
	QJsonObject Record_to_JsonObject(const QSqlRecord& record);

public:
	Server();

public:
	void Layoutinit();
	void Connectinit();
	void Update_navigation_view(QString data = "0");
	void Update_data_view(QString data = QString("[%1] 网络网址已成功连接老!").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));


};

#endif // !SERVER_U
